define(function(require, exports){
	var $ = require('jquery');
	var util = require('util');
	var pubjs = require('pubjs');
	var grid  = require('@base/highGrid');

	var STATUS = pubjs.config('TASK_STATUS');

	var Base = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'sync/list',
					cols: [
						{name:'_id',text:"ID", sort: true, align: 'center', width: 60},
						{name:'AdxText',text:"渠道", sort: true, align: 'center', width: 150},
						{name:'TypeText',text:"类型", sort: true, align: 'center', width: 100},
						{name:'Status',text:LANG("状态"), render: 'renderStatus', align: 'center',width:250},
						{name:'Period',text:LANG("时间段"), align: 'center',width:200},
						{name:'SyncCount',text:LANG("同步数目"), align: 'center',width:50,format:'numberFormat'},
						{name:'_CreateTime',text:LANG("创建时间"), render: 'renderCreateTime', align: 'center' ,width: 200},
						{name:'Time',text:LANG("消耗时间"), render: 'renderTime', align: 'center',width:50}
					],
					hasAmount: false,
					hasTab: false,
					hasMenu: true,
					hasExport: false,
					hasBatch: false,
					hasSelect: true,
					isSendMetrics: false,
					reqType: 'websocket',
					gridName: 'customDownload'
				}
			);

			this.Super('init', arguments);
		}
		,renderStatus: function(i, val, data)
		{
			var str = LANG('未知');
			switch (val)
			{
				case STATUS.DONE:
					str = LANG('已完成');
					break;
				case STATUS.FAIL:
					str = LANG('同步失败: ') + data.Info;
					break;
				case STATUS.WAIT:
				case STATUS.ING:
					str = LANG('进行中');
					break;
				case STATUS.PAUSE:
					str = LANG('已中止');
					break;
			}

			return $('<div class="text-truncate"/>').text(str).attr('title', str);
		}
		,renderTime: function(data, val)
		{
			if(val)
			{
				return Math.round(val/1000, 2) + LANG('秒');
			}
			else
			{
				return '--';
			}
		}
		,renderCreateTime: function(i, val, data)
		{
			if(data.CreateTime)
			{
				return util.date("Y年m月d日", data.CreateTime);
			}
			else
			{
				return '--';
			}
		}
	});

	exports.base = Base;

});